﻿using DevExpress.XtraEditors.Controls;
using DevExpress.XtraEditors.Repository;
using DevExpress.XtraGrid;
using DevExpress.XtraGrid.Views.Grid;
using Lamex.Base;
using Lamex.Interface;
using Lamex.Library;
using Lamex.Library.CommonClass;
using Lamex.mIE.DalServer;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Lamex.mIE.UI
{
    public partial class Frm_IE_Part_SizeParmList_Foam : frmBaseChild
    {
        static string list_Moudle = "", list_Type = "", list_FOAM_PROCESS = "", list_RAW_MAT_SIZE = "";
        static DataTable dtList = new DataTable();
        public Frm_IE_Part_SizeParmList_Foam()
        {
            InitializeComponent();
        }
        public Frm_IE_Part_SizeParmList_Foam(string strPart_No)
        {
            InitializeComponent();
            txtPart_No.Text = strPart_No;
        }
        private void Frm_IE_Part_SizeParmList_Foam_Load(object sender, EventArgs e)
        {
            try { this.InitButtons(); } catch { }//初始化标准功能，因要应用于RibbonForm，所以加入异常处理

            Init();
            GetData();
        }
        public void Init()
        {
            DataTable dt = new DataTable();//定义一个空的尺寸参数表，方便动态添加数据
            dt.Columns.Add("MOUDLE_NAME");
            dt.Columns.Add("FOAM_TYPE");
            dt.Columns.Add("REQUIRE_QTY");
            dt.Columns.Add("FOAM_CUT_LEN");
            dt.Columns.Add("FOAM_CUT_WIDTH");
            dt.Columns.Add("FOAM_CUT_THICK");
            dt.Columns.Add("FOAM_PROCESS");
            dt.Columns.Add("RAW_MAT_SIZE");
            gridControl1.DataSource = dt;
            gridView1.OptionsView.ColumnAutoWidth = false;
            this.gridView1.BestFitColumns();
            //获取模板名称和软体材质
            DataTable dtMoudle = BaseBuildSql.GetDataTableBySql(@"select FIELD_VALUE_OPTION FROM [LamexMESManager].[dbo].[Sys_ControlValueOption] where FIELD_NAME='MOUDLE_NAME'");
            DataTable dtType = BaseBuildSql.GetDataTableBySql("select FIELD_VALUE_OPTION FROM [LamexMESManager].[dbo].[Sys_ControlValueOption] where FIELD_NAME='FOAM_TYPE'");
            DataTable dtProcess = BaseBuildSql.GetDataTableBySql(@"select FIELD_VALUE_OPTION FROM [LamexMESManager].[dbo].[Sys_ControlValueOption] where FIELD_NAME='FOAM_PROCESS'");
            DataTable dtMatSize = BaseBuildSql.GetDataTableBySql("select FIELD_VALUE_OPTION FROM [LamexMESManager].[dbo].[Sys_ControlValueOption] where FIELD_NAME='RAW_MAT_SIZE'");

            if (dtMoudle.Rows.Count > 0)
                list_Moudle = dtMoudle.Rows[0]["FIELD_VALUE_OPTION"].ToString();
            if (dtType.Rows.Count > 0)
                list_Type = dtType.Rows[0]["FIELD_VALUE_OPTION"].ToString();
            if (dtProcess.Rows.Count > 0)
                list_FOAM_PROCESS = dtProcess.Rows[0]["FIELD_VALUE_OPTION"].ToString();
            if (dtMatSize.Rows.Count > 0)
                list_RAW_MAT_SIZE = dtMatSize.Rows[0]["FIELD_VALUE_OPTION"].ToString();
        }
        //新增
        public override void DoAdd(IButtonInfo sender)
        {
            //gridView1.AddNewRow();
        }
        //保存
        public override void DoSave(IButtonInfo sender)
        {
            try
            {
                #region 按钮权限
                if (!BuildSqlHelper.IsExistList("IE_Part_SizeParmList_Foam", "LamexMESManager")) return;
                #endregion
                int iRow = gvPart_List.FocusedRowHandle;
                if (iRow < 0)
                {
                    DevExpress.XtraEditors.XtraMessageBox.Show("部件编号不能为空，请检查！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                string strPART_NO = gvPart_List.GetRowCellDisplayText(iRow, "PART_NO").ToString();//部件号
                DataTable dtResult = Common.GetTable.GetSizeParmList_Foam();
                DataTable dt = ((DataView)gridView1.DataSource).ToTable();
                if (dt.Rows.Count > 0)
                {
                    DataView dv = new DataView(dt);
                    if (dv.Count != dv.ToTable(true, "MOUDLE_NAME").Rows.Count)
                    {
                        DevExpress.XtraEditors.XtraMessageBox.Show("模板名称有重复，请检查！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }

                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        if (dt.Rows[i]["MOUDLE_NAME"].ToString().Length <= 0)
                            continue;
                        DataRow dr = dtResult.NewRow();
                        dr["PART_NO"] = strPART_NO;
                        dr["MOUDLE_NAME"] = dt.Rows[i]["MOUDLE_NAME"].ToString();
                        dr["FOAM_TYPE"] = dt.Rows[i]["FOAM_TYPE"].ToString();
                        dr["REQUIRE_QTY"] = dt.Rows[i]["REQUIRE_QTY"].ToString().Length > 0 ? dt.Rows[i]["REQUIRE_QTY"].ToString() : null;
                        dr["FOAM_CUT_LEN"] = dt.Rows[i]["FOAM_CUT_LEN"].ToString().Length > 0 ? dt.Rows[i]["FOAM_CUT_LEN"].ToString() : null;
                        dr["FOAM_CUT_WIDTH"] = dt.Rows[i]["FOAM_CUT_WIDTH"].ToString().Length > 0 ? dt.Rows[i]["FOAM_CUT_WIDTH"].ToString() : null;
                        dr["FOAM_CUT_THICK"] = dt.Rows[i]["FOAM_CUT_THICK"].ToString().Length > 0 ? dt.Rows[i]["FOAM_CUT_THICK"].ToString() : null;
                        dr["FOAM_PROCESS"] = dt.Rows[i]["FOAM_PROCESS"].ToString().Length > 0 ? dt.Rows[i]["FOAM_PROCESS"].ToString() : null;
                        dr["RAW_MAT_SIZE"] = dt.Rows[i]["RAW_MAT_SIZE"].ToString().Length > 0 ? dt.Rows[i]["RAW_MAT_SIZE"].ToString() : null;
                        dr["UPDATE_USER"] = Lamex.Common.Loginer.CurrentUser.AccountName;
                        dr["UPDATE_TIME"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
                        if (dr["REQUIRE_QTY"].ToString().Trim().Length <= 0 || dr["FOAM_CUT_LEN"].ToString().Trim().Length <= 0 || dr["FOAM_CUT_WIDTH"].ToString().Trim().Length <= 0 || dr["FOAM_CUT_THICK"].ToString().Trim().Length <= 0
                            || dr["FOAM_PROCESS"].ToString().Trim().Length <= 0 || dr["RAW_MAT_SIZE"].ToString().Trim().Length <= 0)
                        {
                            DevExpress.XtraEditors.XtraMessageBox.Show("存在空值，不允许保存，请检查！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        dtResult.Rows.Add(dr);

                    }
                    //获取工艺路线
                    string strRouting = @"SELECT c.ROUTING_CODE
  FROM [LamexMESManager].[dbo].[IE_Part_Routing] r 
  join [LamexMESManager].[dbo].[IE_Routing_Combination] c on r.GROUP_CODE=c.GROUP_CODE
  where  r.PART_NO='" + strPART_NO + "'";
                    DataTable dtrouting = BaseBuildSql.GetDataTableBySql(strRouting);
                    string[] listR = dtrouting.Rows[0]["ROUTING_CODE"].ToString().Split('_');//一定会存在工艺路线，故这里不需再判断非空

                    //判断数据库是否存在，存在则先删除再插入
                    string sqlPartNo = @" select PART_NO FROM [LamexMESManager].[dbo].[IE_Part_SizeParmList_Foam]
  where PART_NO='" + strPART_NO + "'";
                    DataTable dtPartNo = BaseBuildSql.GetDataTableBySql(sqlPartNo);
                    if (dtPartNo.Rows.Count > 0)
                    {
                        string delPartNo = @"delete  FROM [LamexMESManager].[dbo].[IE_Part_SizeParmList_Foam]
  where PART_NO='" + strPART_NO + "'";
                        BaseBuildSql.ExecuteNonQuery(delPartNo);
                    }
                    //批量插入数据库
                    if (BaseBuildSql.ExcuteInsert(dtResult, "IE_Part_SizeParmList_Foam"))
                    {
                        if (listR.Contains("S03") && listR.Contains("S02"))
                        {
                            //更新【IE_Part_TaskList】的“尺寸录入标识” --椅子布要存在数据
                            DataTable dtFabric = BaseBuildSql.GetDataTableBySql(@" select PART_NO FROM [LamexMESManager].[dbo].[IE_Part_SizeParmList_Fabric]
 where PART_NO='" + strPART_NO + "'");
                            if (dtFabric.Rows.Count > 0)
                            {
                                string UpdateSql = @"update IE_Part_TaskList set PARM_FLAG='1' where PART_NO='" + strPART_NO + "' and  ISNULL(UPLOAD_FLAG,'')!='1'";
                                BaseBuildSql.ExecuteNonQuery(UpdateSql);
                            }
                        }
                        else
                        {
                            string UpdateSql = @"update IE_Part_TaskList set PARM_FLAG='1' where PART_NO='" + strPART_NO + "' and  ISNULL(UPLOAD_FLAG,'')!='1'";
                            BaseBuildSql.ExecuteNonQuery(UpdateSql);
                        }
                        DevExpress.XtraEditors.XtraMessageBox.Show("保存成功，共【" + dt.Rows.Count + "】条！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        //按导入时间降序刷新
                        DoView(null);
                    }
                }
            }
            catch (Exception ex)
            {
                DevExpress.XtraEditors.XtraMessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private void txtRef_PartNo_UcKeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyValue == 13)
            {
                string sql = @"SELECT  [PART_NO]
      ,[MOUDLE_NAME]
      ,[FOAM_TYPE]
      ,[REQUIRE_QTY]
      ,[FOAM_CUT_LEN]
      ,[FOAM_CUT_WIDTH]
      ,[FOAM_CUT_THICK]
      ,[FOAM_PROCESS]
      ,[RAW_MAT_SIZE]
      ,[UPDATE_TIME]
      ,[UPDATE_USER]
  FROM [LamexMESManager].[dbo].[IE_Part_SizeParmList_Foam] where PART_NO='" + txtRef_PartNo.Text.Trim() + "'";



                gridControl1.DataSource = new DataTable();
                // gcPart_List.DataSource = new DataTable();
                DataTable dt = BaseBuildSql.GetDataTableBySql(sql);

                //DataView dv = new DataView(dt);
                //DataTable dtResult = dv.ToTable(true, new[] {"PART_NO" });

                gridControl1.DataSource = dt;
                //gcPart_List.DataSource = dtResult;
                gridView1.OptionsView.ColumnAutoWidth = false;
                this.gridView1.BestFitColumns();
            }
        }

        private void gcPart_List_Click(object sender, EventArgs e)
        {
            txtProduct_Desc.Text = "";
            if (dtList.Rows.Count <= 0)
                return;
            int iRow = gvPart_List.FocusedRowHandle;
            string strPART_NO = gvPart_List.GetRowCellDisplayText(iRow, "PART_NO").ToString();//部件号
            string sql = @"SELECT
      [PART_NO]
      ,[MOUDLE_NAME]
      ,[FOAM_TYPE]
      ,[REQUIRE_QTY]
      ,[FOAM_CUT_LEN]
      ,[FOAM_CUT_WIDTH]
      ,[FOAM_CUT_THICK]
      ,[FOAM_PROCESS]
      ,[RAW_MAT_SIZE]
      ,[UPDATE_TIME]
      ,[UPDATE_USER]
  FROM [LamexMESManager].[dbo].[IE_Part_SizeParmList_Foam] where PART_NO='" + strPART_NO + "'";
            DataTable dt = BaseBuildSql.GetDataTableBySql(sql);
            gridControl1.DataSource = new DataTable();
            gridControl1.DataSource = dt;
            gridView1.OptionsView.ColumnAutoWidth = false;
            this.gridView1.BestFitColumns();
            DataRow[] dr_Desc = dtList.Select("PART_NO='" + strPART_NO + "'");
            if (dr_Desc.Length > 0)
            {
                txtProduct_Desc.Text = dr_Desc[0]["CN_DESC"].ToString();
                txtProductTpye.Text = dr_Desc[0]["MODEL_NO"].ToString();
            }
        }
        //查询
        public override void DoView(IButtonInfo sender)
        {
            GetData();
        }
        public void GetData()
        {
            string sql = txtPart_No.Text.Length > 0 ? " and T.PART_NO='" + txtPart_No.Text + "'" : " and T.PART_NO like '%%'";
            gridControl1.DataSource = new DataTable();
            gcPart_List.DataSource = new DataTable();
            dtList = new DataTable();


            //else
            //{
            //获取任务清单尺寸参数标识不为1工艺路线为1的数据
            dtList = BaseBuildSql.GetDataTableBySql(@"SELECT 
       r.[PART_NO],
       M.CN_DESC,   
       M.MODEL_NO 
  FROM [LamexMESManager].[dbo].[IE_Part_Routing] r 
  join [LamexMESManager].[dbo].[IE_Routing_Combination] c on r.GROUP_CODE=c.GROUP_CODE
  join IE_Part_TaskList t on t.PART_NO=r.PART_NO 
  join IE_Part_MasterData m ON m.PART_NO=r.PART_NO
  where 1=1 " + sql + " and ISNULL(T.PARM_FLAG,'')!='1' and ISNULL(T.ROUTING_FLAG,'')='1' and ISNULL(T.UPLOAD_FLAG,'')!='1' and c.ROUTING_CODE like '%S03%' and M.MRP_CONTROLLER not in ('WG1','PG1') and ISNULL(T.LOCK_FLAG,'')!='1' ");
            // }
            if (txtPart_No.Text.Trim().Length > 0)
            {
                DataTable dtList1 = Common.GetDWG_List.Dwg_List(@"IE_Part_SizeParmList_Foam R JOIN IE_Part_TaskList T on  R.PART_NO=T.PART_NO JOIN IE_Part_MasterData M ON M.PART_NO=T.PART_NO",
                  "distinct T.PART_NO,M.CN_DESC,M.MODEL_NO ",
                  " " + sql + "  and ISNULL(T.PARM_FLAG,'')='1' and ISNULL(T.UPLOAD_FLAG,'')!='1' and M.MRP_CONTROLLER not in ('WG1','PG1') and ISNULL(T.LOCK_FLAG,'')!='1' ");
                //合并临时表
                dtList.Merge(dtList1);
            }
            //若有重复项则去掉


            DataTable Dis_Temp1 = dtList.DefaultView.ToTable(true, new[] { "PART_NO" });
            DataTable Dis_DWG = dtList.Clone();
            for (int i = 0; i < Dis_Temp1.Rows.Count; i++)
            {
                DataRow dr = Dis_DWG.NewRow();
                dr["PART_NO"] = Dis_Temp1.Rows[i]["PART_NO"].ToString();
                Dis_DWG.Rows.Add(dr);
            }
            gcPart_List.DataSource = Dis_DWG;


        }
        //导入
        public override void DoImport(IButtonInfo sender)
        {
            #region 按钮权限
            if (!BuildSqlHelper.IsExistList("IE_Part_SizeParmList_Foam", "LamexMESManager")) return;
            #endregion
            //DevExpress.XtraEditors.XtraMessageBox.Show("未上载数据中，图纸编号+部件编号重复时，原有记录将进行覆盖！！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            //OpenFileDialog dlg = new OpenFileDialog();
            //DataTable dtEqual = new DataTable();//获取导入文件和数据库未上载标识 图纸号+部件号相同值
            //List<string> Temp1 = new List<string>();
            //List<string> Temp2 = new List<string>();
            //StringBuilder sbFilter1 = new StringBuilder();
            //StringBuilder sbFilter2 = new StringBuilder();
            //if (DialogResult.OK == dlg.ShowDialog())
            //{
            //    try
            //    {
            //        SplashScreenTool.ShowSplashScreen(typeof(WaitForm1));
            //        string path = dlg.FileName;
            //        //导入EXCEL转换成Table
            //        DataTable dtImport = Lamex.Common.ExecelHelper.ExcelToDataTable(path, 1);
            //        if (dtImport.Rows.Count <= 0)
            //        {
            //            DevExpress.XtraEditors.XtraMessageBox.Show("导入数据为空！");
            //            return;
            //        }

            //        //查询数据库表-上载标识不等于1
            //        DataTable dt = BaseFactory<IE_Part_SizeParmList>.Instance.GetDataSet().Tables[0];

            //        for (int i = 0; i < dtImport.Rows.Count; i++)
            //        {

            //            //找出未上载的重复值
            //            for (int j = 0; j < dt.Rows.Count; j++)
            //            {
            //                if (dtImport.Rows[i]["图纸编号"].ToString() + dtImport.Rows[i]["部件编号"] ==
            //                    dt.Rows[j]["DWG_NO"].ToString() + dt.Rows[j]["PART_NO"].ToString())
            //                {
            //                    Temp1.Add(dt.Rows[j]["DWG_NO"].ToString());
            //                    Temp2.Add(dt.Rows[j]["PART_NO"].ToString());
            //                }
            //            }
            //        }
            //        //删除上载标识不等于1的重复项
            //        if (Temp1.Count > 0 && Temp2.Count > 0)
            //        {
            //            sbFilter1.AppendFormat(@" AND DWG_NO IN ('{0}')", string.Join("','", Temp1.ToArray()));
            //            sbFilter2.AppendFormat(@" AND PART_NO IN ('{0}')", string.Join("','", Temp2.ToArray()));

            //            string sqlDel = @"Delete  FROM IE_Part_SizeParmList where 1=1  " + sbFilter1 + " " + sbFilter2 + " AND ISNULL(SAP_VERSION,'')='' ";
            //            int n = BaseBuildSql.ExecuteNonQuery(sqlDel);
            //        }
            //        //添加导入时间和导入用户
            //        //添加两新列，其值为默认值
            //        DataColumn dc1 = new DataColumn("LATEST_SAVE_TIME", typeof(DateTime));
            //        dc1.DefaultValue = DateTime.Now;
            //        dc1.AllowDBNull = false;//这在创建表的时候，起作用，在为已有表新增列的时候，不起作用
            //        dtImport.Columns.Add(dc1);
            //        DataColumn dc2 = new DataColumn("UPDATE_USER", typeof(string));
            //        dc2.DefaultValue = Lamex.Common.Loginer.CurrentUser.AccountName;
            //        dc2.AllowDBNull = false;
            //        dtImport.Columns.Add(dc2);

            //        //重新调整导入Table的列名
            //        dtImport.Columns["图纸编号"].ColumnName = "DWG_NO";
            //        dtImport.Columns["部件编号"].ColumnName = "PART_NO";
            //        dtImport.Columns["阔度_1"].ColumnName = "WIDTH_1";
            //        dtImport.Columns["阔度_2"].ColumnName = "WIDTH_2";
            //        dtImport.Columns["深度_1"].ColumnName = "DEPTH_1";
            //        dtImport.Columns["深度_2"].ColumnName = "DEPTH_2";
            //        dtImport.Columns["厚度"].ColumnName = "THICK";
            //        dtImport.Columns["长度"].ColumnName = "LENGTH";
            //        dtImport.Columns["宽度"].ColumnName = "WIDTH";
            //        dtImport.Columns["高度"].ColumnName = "HEIGHT";

            //        //批量插入数据库
            //        if (BaseBuildSql.ExcuteInsert(dtImport, "IE_Part_SizeParmList"))
            //        {
            //            DevExpress.XtraEditors.XtraMessageBox.Show("数据导入成功！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            //        }
            //        SplashScreenTool.CloseSplashScreen();

            //    }
            //    catch (Exception ex)
            //    {
            //        DevExpress.XtraEditors.XtraMessageBox.Show(ex.Message);
            //    }
            //}

        }
        //导出-默认路径D:\MESTemp
        public override void DoExport(IButtonInfo sender)
        {

            if (!Directory.Exists(@"D:\MESTemp"))
                Directory.CreateDirectory(@"D:\MESTemp");
            SaveFileDialog fileDialog = new SaveFileDialog();
            fileDialog.Title = "导出Excel";
            fileDialog.InitialDirectory = @"D:\MESTemp";//导出默认路径
            fileDialog.Filter = "Excel文件(*.xlsx)|*.xlsx";//导出默认格式
            fileDialog.FileName = "MES_TEMP_" + DateTime.Now.ToString("yyMMdd_hhMMss");//导出默认名称
            DialogResult dialogResult = fileDialog.ShowDialog(this);
            if (dialogResult == DialogResult.OK)
            {
                //导出表【IE_Part_TaskList】中当前产品类型，无“尺寸参数标识”的数据
                DataTable dtList = BaseBuildSql.GetDataTableBySql(@"SELECT [PART_NO]
      ,[MOUDLE_NAME]
      ,[FOAM_TYPE]
      ,[REQUIRE_QTY]
      ,[FOAM_CUT_LEN]
      ,[FOAM_CUT_WIDTH]
      ,[FOAM_CUT_THICK]
      ,[FOAM_PROCESS]
      ,[RAW_MAT_SIZE]
      ,[UPDATE_TIME]
      ,[UPDATE_USER]
  FROM [LamexMESManager].[dbo].[IE_Part_SizeParmList_Foam]  ");


                GridControl grid = new GridControl();
                GridView view = new GridView();
                grid.ViewCollection.Add(view);
                grid.MainView = view;
                view.GridControl = grid;
                foreach (DataColumn dc in dtList.Columns)
                {
                    DevExpress.XtraGrid.Columns.GridColumn gridColumnNumber = view.Columns.AddVisible(dc.ColumnName);
                    gridColumnNumber.FieldName = dc.ColumnName;
                }
                grid.DataSource = dtList;
                this.Controls.Add(grid);
                grid.ForceInitialize();
                view.BestFitColumns();
                view.ExportToXlsx(fileDialog.FileName);
                // DevExpress.XtraEditors.XtraMessageBox.Show("导出成功！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                if (DevExpress.XtraEditors.XtraMessageBox.Show("导出成功，是否打开文件？", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                    System.Diagnostics.Process.Start(fileDialog.FileName);//打开指定路径下的文件

            }
        }
        public DialogResult ConfirmDelete()
        {
            return DevExpress.XtraEditors.XtraMessageBox.Show("数据暂未保存，是否保存？", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
        }

        private void Frm_IE_Part_SizeParmList_Foam_FormClosed(object sender, FormClosedEventArgs e)
        {
            //解除当前用户锁定的图号
            Common.GetLock.UnLock();
        }

        private void gridView1_CustomRowCellEdit(object sender, DevExpress.XtraGrid.Views.Grid.CustomRowCellEditEventArgs e)
        {
            if (e.Column.FieldName == "MOUDLE_NAME")
            {
                RepositoryItemComboBox cb = new RepositoryItemComboBox();
                if (list_Moudle.Length <= 0)
                    return;
                string[] Values = list_Moudle.Split(',');
                foreach (var item in Values)
                {
                    cb.Items.Add(item);
                }
                cb.TextEditStyle = TextEditStyles.DisableTextEditor;//设置不可编辑
                e.RepositoryItem = cb;

            }
            if (e.Column.FieldName == "FOAM_TYPE")
            {
                RepositoryItemComboBox cb = new RepositoryItemComboBox();
                if (list_Type.Length <= 0)
                    return;
                string[] Values = list_Type.Split(',');
                foreach (var item in Values)
                {
                    cb.Items.Add(item);
                }
                cb.TextEditStyle = TextEditStyles.DisableTextEditor;//设置不可编辑
                e.RepositoryItem = cb;
            }
            if (e.Column.FieldName == "FOAM_PROCESS")
            {
                RepositoryItemComboBox cb = new RepositoryItemComboBox();
                if (list_FOAM_PROCESS.Length <= 0)
                    return;
                string[] Values = list_FOAM_PROCESS.Split(',');
                foreach (var item in Values)
                {
                    cb.Items.Add(item);
                }
                cb.TextEditStyle = TextEditStyles.DisableTextEditor;//设置不可编辑
                e.RepositoryItem = cb;
            }
            if (e.Column.FieldName == "RAW_MAT_SIZE")
            {
                RepositoryItemComboBox cb = new RepositoryItemComboBox();
                if (list_RAW_MAT_SIZE.Length <= 0)
                    return;
                string[] Values = list_RAW_MAT_SIZE.Split(',');
                foreach (var item in Values)
                {
                    cb.Items.Add(item);
                }
                cb.TextEditStyle = TextEditStyles.DisableTextEditor;//设置不可编辑
                e.RepositoryItem = cb;
            }
        }

        private void toolStripMenuItem1_Click(object sender, EventArgs e)
        {
            gridView1.AddNewRow();
        }

        private void toolStripMenuItem2_Click(object sender, EventArgs e)
        {
            gridView1.DeleteSelectedRows();
        }

    }
}
